for value in range(1,5):
    print(value)

print('------')
#使用函数list将range的结果转换为列表
numberList = list(range(1,6))
for num in numberList:
    print(num)

print('------')

even_numbers = list(range(2,11,2));
for num in even_numbers:
    print(num)

print('------')

squares = []
for value in range(1,11):
    square = value ** 2
    squares.append(square)
    print(squares)

#对数字列表执行简单的统计运算
digits = [1,2,3,4,5,6,7,8,9]
print(min(digits))
print(max(digits))
print(sum(digits))

#列表解析
squares_ = [val ** 2 for val in range(1,11)]
print(squares_)

#练习
for num in range(1,21):
    print(num)

listMilion = [val for val in range(1, 1000001)]
print(listMilion)
print(min(listMilion))
print(max(listMilion))
print(sum(listMilion))

oddList = [val  for val in range(1,21,2)]
print(oddList)

example_list = []
for val in range(0,31):
    if val % 3 == 0 and val != 0:
        example_list.append(val)
print(example_list)

cubList = [val ** 3 for val in range(0,11)]
print(cubList)


#切片
players = ['charles','martina','michael','florence','eli']
print(players[0:3])
print(players[1:4])
print(players[:4])

print('here are the first three players on my team:')
for player in players[:3]:
    print(player.title())

#复制列表
my_foods = ['pizza','falafel','carrot cake']
friend_foods = my_foods[:]
print('my favorite foods are:')
print(my_foods)
print('\nmy friend\'s favorite foods are:')
print(friend_foods)

my_foods.append('cannoli')
friend_foods.append('ice cream')
print('my favorite foods are:')
print(my_foods)

print('\nmy friend\'s favorite foods are:')
print(friend_foods)

#练习
print('the first three items in the list are:')
print(players[:3])
print('three items from the middle of the list are:')
print(players[1:4])
print('the last three items in the list are:')
print(players[-3:])

#元组,是不可修改的列表
dimensions = (200,50)
print(dimensions[0])
print(dimensions[1])

for dimension in dimensions:
    print(dimension)

#修改元组变量
dimensions = (400,100)
print('\nmodified dimensions:')
for dimension in dimensions:
    print(dimension)

#练习
orderedFoods = ('pizza','falafel','carrot cake')
for food in orderedFoods:
    print(food)

#尝试修改元组元素
#orderedFoods[0] = 'ice cream'

#替换元组中的元素
orderedFoods = ('ice cream','falafel','carrot cake')
for food in orderedFoods:
    print(food)

#设置代码格式
#缩进
#行长
#空行
#使用合适的长度
#不要使用的水平空间
